//Copyright 2010 Balazs Keri, Imre Keri
//
//This file is part of FireworksCreator.
//
//FireworksCreator is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//FireworksCreator is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with FireworksCreator.  If not, see <http://www.gnu.org/licenses/>.
//
#include "randomposition.h"
//
namespace model
{
RandomPosition::Constant::Constant(const osg::Vec3 &p_value)
:
   Data(type_constant),
   value(p_value)
{
}
const osg::Vec3 &RandomPosition::Constant::get_value()const
{
   return value;
}
void RandomPosition::Constant::set_value(const osg::Vec3 &p_value)
{
   value=p_value;
}
osg::Vec3 RandomPosition::Constant::calculate()const
{
   return value;
}
MultiTypeData *RandomPosition::Constant::clone()const
{
   return new Constant(value);
}
void RandomPosition::Constant::store(QDataStream &p_stream)const
{
   p_stream<<value;
}
void RandomPosition::Constant::restore(QDataStream &p_stream)
{
   p_stream>>value;
}
//
RandomPosition::Box::Box(const osg::Vec3 &p_min,const osg::Vec3 &p_max)
:
   Data(type_box),
   min(p_min),max(p_max)
{
}
const osg::Vec3 &RandomPosition::Box::get_min()const
{
   return min;
}
void RandomPosition::Box::set_min(const osg::Vec3 &p_min)
{
   min=p_min;
}
const osg::Vec3 &RandomPosition::Box::get_max()const
{
   return max;
}
void RandomPosition::Box::set_max(const osg::Vec3 &p_max)
{
   max=p_max;
}
osg::Vec3 RandomPosition::Box::calculate()const
{
   return osg::Vec3(qrand_interval<float>(min.x(),max.x()),qrand_interval<float>(min.y(),max.y()),qrand_interval<float>(min.z(),max.z()));
}
MultiTypeData *RandomPosition::Box::clone()const
{
   return new Box(min,max);
}
void RandomPosition::Box::store(QDataStream &p_stream)const
{
   p_stream<<min<<max;
}
void RandomPosition::Box::restore(QDataStream &p_stream)
{
   p_stream>>min>>max;
}
}
